<template>
  <div class="song">
    <div class="songListHeader">
      <div class="songBackground">
        <div :style="{'backgroundImage':`url(${firstSong.coverImgUrl})`}"></div>
      </div>
      <div class="songHeader">
        <img :src="firstSong.coverImgUrl" alt width="160" height="160" />
        <div class="songDetail">
          <div class="songGood">
            <i class="iconfont iconhuangguan"></i>
            <span>精品歌单</span>
          </div>
          <div class="songinfo">
            <div>{{firstSong.name}}</div>
            <div>{{firstSong.copywriter}}</div>
          </div>
        </div>
      </div>
    </div>
    <song-info @changeCate="changeCate"></song-info>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue'
import axios from '@/http.ts'
import songInfo from './songdetail.vue'
onMounted(() => {
  getFirstPageSong()
})
const currentCate = ref<string>('全部')
const firstSong = ref({
  coverImgUrl: ''
})
const changeCate = tag => {
  currentCate.value = tag
  getFirstPageSong()
}
const getFirstPageSong = () => {
  axios
    .get('/top/playlist/highquality', {
      params: {
        limit: 1,
        cat: currentCate.value
      }
    })
    .then(res => {
      firstSong.value = res.data.playlists[0]
    })
}
</script>

<style lang="scss" scoped>
.song {
  padding: 10px 30px;
  position: relative;
  .songListHeader {
    border-radius: 5px;
    overflow: hidden;
    .songBackground {
      border-radius: 5px;
      width: calc(100% - 60px);
      height: 200px;
      overflow: hidden;
      position: absolute;
      background-attachment: fixed;
      div {
        width: 100%;
        position: absolute;
        z-index: 0;
        height: 180px;
        padding: 15px;
        filter: blur(30px);
      }
    }
    .songHeader {
      box-sizing: border-box;
      background-color: rgba(94, 94, 94, 0.5);
      position: relative;
      z-index: 9;
      width: 100%;
      height: 200px;
      padding: 15px;
      display: flex;
      img {
        border-radius: 5px;
        margin-right: 16px;
      }
      .songDetail {
        padding: 28px 0;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .songGood {
          margin-bottom: 10px;
          padding: 15px 0;
          font-size: 13px;
          font-weight: bolder;
          width: 90px;
          height: 24px;
          border: 1px solid #edac67;
          color: #edac67;
          padding: 3px 7px;
          border-radius: 30px;
          line-height: 23px;
          text-align: center;
          i {
            margin-right: 5px;
          }
        }
        .songinfo {
          div:nth-child(1) {
            color: #fff;
            font-weight: bold;
            font-size: 17px;
          }
          div:nth-child(2) {
            color: #a9a9ad;
            font-size: 12px;
            margin-top: 10px;
            height: 19px;
          }
        }
      }
    }
  }
}
</style>